const args = require('minimist')(process.argv.slice(2))
// 动态规划
function stairs(n: number): number {
    let arr: number[] = []
    for (let i = 1, len = n; i <= len; i++) {
        if (i === 1 ) {
            arr[i] = 1
        } else if (i === 2) {
            arr[i] = 2
        } else {
            arr[i] = arr[i - 1] + arr[i - 2]
        }
    }
    return arr[arr.length - 1]
}
// 传统递归
function stairsRecursion(n: number): number {
    function callSelf (x: number):number {
        if (x === 1) return 1
        if (x === 2) return 2
        return callSelf(x-1) + callSelf(x-2)
    }
    return callSelf(n)
}
console.log('动态规划', stairs(args['n']))
console.log('传统递归', stairsRecursion(args['n']))